/**
 *  @file TimeDuration.h
 */
#ifndef _TIMEDURATION_H_
#define _TIMEDURATION_H_

#include "../common/BaseObject.h"

namespace cppflib
{

namespace util
{

/**
 *  A class to represent a duration/period of time (can be +ve or -ve)
 */
class _DLLAPI TimeDuration : public BaseObject
{
private:
    i64_t ticks;   ///< one unit is 100 nanosecond or 10^-7 sec or 0.0000001 sec

    TimeDuration(void);
    void InitTicks(int days, int hours, int mins, int secs, int milliSecs);
    void ReleaseBeforeThrowing();

public:
    explicit TimeDuration(i64_t ticks);
    TimeDuration(int hours, int mins, int secs);
    TimeDuration(int days, int hours, int mins, int secs);
    TimeDuration(int days, int hours, int mins, int secs, int milliSecs);
    virtual ~TimeDuration(void);

    TimeDuration& Add(const TimeDuration &td);
    TimeDuration& Negate();
    TimeDuration& MakeAbsolute();
 
    int Compare(const TimeDuration &td) const;

    bool IsNeg() const;
    int Days() const;
    int Hours() const;
    int Mins() const;
    int Seconds() const;
    int MilliSeconds() const;

    int TotalDays() const;
    i64_t TotalHours() const;
    i64_t TotalMins() const;
    i64_t TotalSeconds() const;
    i64_t TotalMilliSeconds() const;
    i64_t TotalTicks() const;
    u64_t TotalAbsoluteTicks() const;
public:
	PUBLIC const i64_t TICKS_PERDAY;
    PUBLIC const i64_t TICKS_PERHOUR;
    PUBLIC const i64_t TICKS_PERMIN;
    PUBLIC const i64_t TICKS_PERSEC;
    PUBLIC const i64_t TICKS_PERMILLISEC;
};

_DLLAPI bool operator==(const TimeDuration& td1, const TimeDuration& td2);
_DLLAPI bool operator!=(const TimeDuration& td1, const TimeDuration& td2);
_DLLAPI bool operator<(const TimeDuration& td1, const TimeDuration& td2);
_DLLAPI bool operator>(const TimeDuration& td1, const TimeDuration& td2);
_DLLAPI bool operator<=(const TimeDuration& td1, const TimeDuration& td2);
_DLLAPI bool operator>=(const TimeDuration& td1, const TimeDuration& td2);


} // end of namespace util

} // end of namespace cppflib


#endif
